package com.cos.students.web.controller;


import com.cos.students.common.Const;
import com.cos.students.common.ResponseResult;
import com.cos.students.entity.RcStudentCourse;
import com.cos.students.services.IRcTeacherService;
import com.cos.students.vo.input.SearchChoseCourseVO;
import com.cos.students.vo.output.LoginInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cos
 * @since 2022-10-24
 */
@RestController
@RequestMapping("/rc-teacher")
public class RcTeacherController {
    @Autowired
    private IRcTeacherService teacherService;

    @PostMapping("/addScore")
    public ResponseResult addScore(RcStudentCourse course){
        return teacherService.addScore(course);
    }
    @GetMapping("/getTeacherCourse")
    public ResponseResult getTeacherCourse(HttpSession session){
        LoginInfoVo infoVo  = (LoginInfoVo) session.getAttribute(Const.IS_LOGIN);
        return teacherService.getTeacherCourse(infoVo.getUserId());
    }

    @GetMapping("/showTeacherCourseTimeTable")
    public ResponseResult showTeacherCourseTimeTable(HttpSession session){
        LoginInfoVo infoVo  = (LoginInfoVo) session.getAttribute(Const.IS_LOGIN);
        return teacherService.showTeacherCourseTimeTable(infoVo.getUserId());
    }

    @GetMapping("/searchStudentScore")
    public ResponseResult searchStudentScore(SearchChoseCourseVO vo,HttpSession session){
        LoginInfoVo infoVo = (LoginInfoVo) session.getAttribute(Const.IS_LOGIN);
        vo.setStudentId(infoVo.getUserId());
        return teacherService.searchStudentScore(vo);
    }
}
